/*
 * @Author: wuqingchun
 * @Date: 2024-06-24 11:29:22
 * @Description: 线程与信号处理程序之前的同步操作
 * @LastEditors: wuqingchun
 * @LastEditTime: 2024-06-24 11:35:19
 */

#include <atomic>
#include <csignal>
#include <cassert>

bool g_bFlag1{false};
bool g_bFlag2{false};

void SigHandler(int iSignal)
{
    if (g_bFlag1)
    {
        assert(g_bFlag2);
    }
}

int main(int argc, char** argv)
{
    std::signal(SIGTERM, SigHandler);

    g_bFlag2 = true;
    g_bFlag1 = true;

    return 0;
}